﻿using SyncCore.Sync.Models;
using System.Net;

namespace SyncCore.Sync.FrameSync
{
    internal class ClientFrameMessage
    {
        public EndPoint EndPoint { get; set; }

        public bool IsChanged { get; private set; }

        public List<CommandMessagePack> Commands { get; set; } = new List<CommandMessagePack>();

        public void Add(CommandMessagePack commandMessagePack)
        {
            if (IsChanged == false)
            {
                if (commandMessagePack != null)
                    Commands.Add(commandMessagePack);
                IsChanged = true;
            }
        }

        public void AddRange(IEnumerable<CommandMessagePack> commandMessagePacks)
        {
            if (IsChanged == false)
            {
                if (commandMessagePacks != null)
                {
                    Commands.AddRange(commandMessagePacks);
                }

                IsChanged = true;
            }
        }



        public void Reset()
        {
            IsChanged = false;
            Commands.Clear();
        }
    }
}
